/* SPDX-License-Identifier: GPL-2.0-or-later
 *
 * Copyright (C) 2016-2018, LomboTech Co.Ltd.
 * Authors:
 *	lomboswer <lomboswer@lombotech.com>
 *
 * This program is free software; you can redistribute  it and/or modify it
 * under  the terms of  the GNU General  Public License as published by the
 * Free Software Foundation;  either version 2 of the  License, or (at your
 * option) any later version.
 */

#ifndef __CSP_DPU_SE_COEF_TAB_C__
#define __CSP_DPU_SE_COEF_TAB_C__

/* scaling coefficients table start */
/* x table */
static unsigned int sc_tab_8taps_type0_0[32] = {
	0x40000000, 0x3FFF0000, 0x3DFE0100, 0x3CFD0100,
	0x3CFC0100, 0x3BFB0200, 0x3AFA0200, 0x39F90200,
	0x38F80200, 0x35F80200, 0x33F80200, 0x31F80200,
	0x2FF80200, 0x2CF80200, 0x2AF80200, 0x28F80200,
	0x25F80200, 0x24F90100, 0x22F90100, 0x1FFA0100,
	0x1CFA0100, 0x19FB0100, 0x17FB0100, 0x14FC0100,
	0x11FD0000, 0x0FFD0000, 0x0CFE0000, 0x0AFE0000,
	0x08FF0000, 0x06000000, 0x04000000, 0x02000000,
};

static unsigned int sc_tab_8taps_type0_1[32] = {
	0x00000000, 0x00000002, 0x00000004, 0x00000006,
	0x0000FF08, 0x0000FE0A, 0x0000FE0C, 0x0000FD0F,
	0x0000FD11, 0x0001FC14, 0x0001FB17, 0x0001FB19,
	0x0001FA1C, 0x0001FA1F, 0x0001F922, 0x0001F924,
	0x0002F827, 0x0002F828, 0x0002F82A, 0x0002F82C,
	0x0002F82F, 0x0002F831, 0x0002F833, 0x0002F835,
	0x0002F838, 0x0002F939, 0x0002FA3A, 0x0002FB3B,
	0x0001FC3C, 0x0001FD3C, 0x0001FE3D, 0x0000FF3F,
};

static unsigned int sc_tab_8taps_type1_0[32] = {
	0x40000000, 0x3F000000, 0x3EFF0000, 0x3DFE0000,
	0x3DFD0000, 0x3BFD0000, 0x3AFC0000, 0x37FC0000,
	0x35FC0000, 0x33FC0000, 0x31FC0000, 0x2FFC0000,
	0x2CFC0000, 0x2AFC0000, 0x27FC0000, 0x25FD0000,
	0x22FD0000, 0x21FD0000, 0x1FFE0000, 0x1CFE0000,
	0x19FF0000, 0x16FF0000, 0x14FF0000, 0x11000000,
	0x0F000000, 0x0D000000, 0x0A000000, 0x08000000,
	0x06000000, 0x05000000, 0x03000000, 0x01000000,
};

static unsigned int sc_tab_8taps_type1_1[32] = {
	0x00000000, 0x00000001, 0x00000003, 0x00000005,
	0x00000006, 0x00000008, 0x0000000A, 0x0000000D,
	0x0000000F, 0x00000011, 0x0000FF14, 0x0000FF16,
	0x0000FF19, 0x0000FE1C, 0x0000FE1F, 0x0000FD21,
	0x0000FD24, 0x0000FD25, 0x0000FC27, 0x0000FC2A,
	0x0000FC2C, 0x0000FC2F, 0x0000FC31, 0x0000FC33,
	0x0000FC35, 0x0000FC37, 0x0000FC3A, 0x0000FD3B,
	0x0000FD3D, 0x0000FE3D, 0x0000FF3E, 0x0000003F,
};

#if 0
static unsigned int sc_tab_8taps_type2[2][32] = {
	{
		0x40000000, 0x3FFF0000, 0x3DFE0100, 0x3CFD0100,
		0x3CFC0100, 0x3BFB0200, 0x3AFA0200, 0x39F90200,
		0x38F80200, 0x35F80200, 0x33F80200, 0x31F80200,
		0x2FF80200, 0x2CF80200, 0x2AF80200, 0x28F80200,
		0x25F80200, 0x24F90100, 0x22F90100, 0x1FFA0100,
		0x1CFA0100, 0x19FB0100, 0x17FB0100, 0x14FC0100,
		0x11FD0000, 0x0FFD0000, 0x0CFE0000, 0x0AFE0000,
		0x08FF0000, 0x06000000, 0x04000000, 0x02000000,
	},
	{
		0x00000000, 0x00000002, 0x00000004, 0x00000006,
		0x0000FF08, 0x0000FE0A, 0x0000FE0C, 0x0000FD0F,
		0x0000FD11, 0x0001FC14, 0x0001FB17, 0x0001FB19,
		0x0001FA1C, 0x0001FA1F, 0x0001F922, 0x0001F924,
		0x0002F827, 0x0002F828, 0x0002F82A, 0x0002F82C,
		0x0002F82F, 0x0002F831, 0x0002F833, 0x0002F835,
		0x0002F838, 0x0002F939, 0x0002FA3A, 0x0002FB3B,
		0x0001FC3C, 0x0001FD3C, 0x0001FE3D, 0x0000FF3F,
	},
};
#endif

static unsigned int sc_tab_8taps_type3_0[32] = {
	0x1F0B0401, 0x1D0B0401, 0x1D0B0401, 0x1B0B0401,
	0x1C0A0401, 0x1B0A0401, 0x1B0A0401, 0x190A0401,
	0x1A090301, 0x1A090301, 0x19090301, 0x19090301,
	0x17090301, 0x16080301, 0x16080301, 0x15080301,
	0x13080301, 0x14070301, 0x13070301, 0x13070301,
	0x12070201, 0x11060201, 0x11060201, 0x10060201,
	0x10060201, 0x0F060201, 0x0E050201, 0x0E050201,
	0x0D050201, 0x0D050201, 0x0C040201, 0x0C040201,
};

static unsigned int sc_tab_8taps_type3_1[32] = {
	0x0101040B, 0x0102040C, 0x0102040C, 0x0102050D,
	0x0102050D, 0x0102050E, 0x0102050E, 0x0102060F,
	0x01020610, 0x01020610, 0x01020611, 0x01020611,
	0x01020712, 0x01030713, 0x01030713, 0x01030714,
	0x01030815, 0x01030815, 0x01030816, 0x01030816,
	0x01030917, 0x01030919, 0x01030919, 0x0103091A,
	0x0103091A, 0x01040A19, 0x01040A1B, 0x01040A1B,
	0x01040A1C, 0x01040B1B, 0x01040B1D, 0x01040B1D,
};

static unsigned int sc_tab_8taps_type4_0[32] = {
	0x120B0704, 0x120B0704, 0x110B0704, 0x120A0604,
	0x120A0604, 0x120A0604, 0x110A0604, 0x0F0A0604,
	0x0F0A0604, 0x0F0A0604, 0x0F0A0604, 0x10090603,
	0x10090603, 0x10090603, 0x0F090603, 0x0F090503,
	0x0F090503, 0x0F090503, 0x0E090503, 0x0E080503,
	0x0E080503, 0x0E080503, 0x0D080503, 0x0D080503,
	0x0D080503, 0x0D080503, 0x0C070503, 0x0C070403,
	0x0C070403, 0x0C070403, 0x0B070403, 0x0B070402,
};

static unsigned int sc_tab_8taps_type4_1[32] = {
	0x0204070B, 0x0204070B, 0x0304070B, 0x0304070C,
	0x0304070C, 0x0304070C, 0x0305070C, 0x0305080D,
	0x0305080D, 0x0305080D, 0x0305080D, 0x0305080E,
	0x0305080E, 0x0305080E, 0x0305090E, 0x0305090F,
	0x0305090F, 0x0305090F, 0x0306090F, 0x03060910,
	0x03060910, 0x03060910, 0x04060A0F, 0x04060A0F,
	0x04060A0F, 0x04060A0F, 0x04060A11, 0x04060A12,
	0x04060A12, 0x04060A12, 0x04070B11, 0x04070B12,
};

/* y table */
static unsigned int sc_tab_4taps_type0[32] = {
	0x00004000, 0x00013F00, 0x00033EFF, 0x00053DFE,
	0x00063DFD, 0x00083BFD, 0x000A3AFC, 0x000D37FC,
	0x000F35FC, 0x001133FC, 0xFF1431FC, 0xFF162FFC,
	0xFF192CFC, 0xFE1C2AFC, 0xFE1F27FC, 0xFD2125FD,
	0xFD2422FD, 0xFD2521FD, 0xFC271FFE, 0xFC2A1CFE,
	0xFC2C19FF, 0xFC2F16FF, 0xFC3114FF, 0xFC331100,
	0xFC350F00, 0xFC370D00, 0xFC3A0A00, 0xFD3B0800,
	0xFD3D0600, 0xFE3D0500, 0xFF3E0300, 0x003F0100,
};

static unsigned int sc_tab_4taps_type1[32] = {
	0x00111E11, 0x00111F10, 0x01121D10, 0x01131D0F,
	0x01131E0E, 0x01141E0D, 0x02141D0D, 0x02151D0C,
	0x03151C0C, 0x03161C0B, 0x04161C0A, 0x04171C09,
	0x05171B09, 0x05181B08, 0x06181A08, 0x06191A07,
	0x07191907, 0x071A1906, 0x081A1806, 0x081B1805,
	0x091B1705, 0x091C1704, 0x0A1C1604, 0x0B1C1603,
	0x0C1C1503, 0x0C1D1502, 0x0D1D1402, 0x0D1E1401,
	0x0E1E1301, 0x0F1D1301, 0x101D1201, 0x101F1100,
};

static unsigned int sc_tab_4taps_type2[32] = {
	0x050D210D, 0x050D220C, 0x050E210C, 0x050E210C,
	0x060F1F0C, 0x06101F0B, 0x06101F0B, 0x06111E0B,
	0x06121D0B, 0x07121D0A, 0x07131C0A, 0x07141B0A,
	0x08141A0A, 0x08151A09, 0x08161909, 0x08171809,
	0x09171709, 0x09181708, 0x09191608, 0x091A1508,
	0x0A1A1408, 0x0A1B1407, 0x0A1C1307, 0x0A1D1207,
	0x0B1D1206, 0x0B1E1106, 0x0B1F1006, 0x0B1F1006,
	0x0C1F0F06, 0x0C210E05, 0x0C210E05, 0x0C220D05,
};

static unsigned int sc_tab_4taps_type3[32] = {
	0x090F190F, 0x090F190F, 0x0910180F, 0x0A10180E,
	0x0A10180E, 0x0A10180E, 0x0A11170E, 0x0B11160E,
	0x0B11160E, 0x0B11160E, 0x0B12160D, 0x0B13150D,
	0x0B13150D, 0x0B13150D, 0x0C13150C, 0x0C14140C,
	0x0C14140C, 0x0C14140C, 0x0C15130C, 0x0D15130B,
	0x0D15130B, 0x0D15130B, 0x0D16120B, 0x0E16110B,
	0x0E16110B, 0x0E16110B, 0x0E17110A, 0x0E18100A,
	0x0E18100A, 0x0E18100A, 0x0F181009, 0x0F190F09,
};

static unsigned int sc_tab_4taps_type4[32] = {
	0x0C101410, 0x0C101410, 0x0C101410, 0x0C101410,
	0x0D10140F, 0x0D11130F, 0x0D11130F, 0x0D11130F,
	0x0D11130F, 0x0D11130F, 0x0D11130F, 0x0D11130F,
	0x0E11130E, 0x0E12120E, 0x0E12120E, 0x0E12120E,
	0x0E12120E, 0x0E12120E, 0x0E12120E, 0x0E12120E,
	0x0E13110E, 0x0F13110D, 0x0F13110D, 0x0F13110D,
	0x0F13110D, 0x0F13110D, 0x0F13110D, 0x0F13110D,
	0x0F14100D, 0x1014100C, 0x1014100C, 0x1014100C,
};

static unsigned int sc_tab_2taps_type0[32] = {
	0x00000040, 0x0000013F, 0x0000033D, 0x0000043C,
	0x0000063A, 0x00000838, 0x00000A36, 0x00000C34,
	0x00000E32, 0x00001030, 0x0000122E, 0x0000142C,
	0x0000162A, 0x00001927, 0x00001B25, 0x00001E22,
	0x00002020, 0x0000221E, 0x0000251B, 0x00002719,
	0x00002A16, 0x00002C14, 0x00002E12, 0x00003010,
	0x0000320E, 0x0000340C, 0x0000360A, 0x00003808,
	0x00003A06, 0x00003C04, 0x00003D03, 0x00003F01,
};

static unsigned int sc_tab_2taps_type1[32] = {
	0x00001729, 0x00001729, 0x00001828, 0x00001927,
	0x00001A26, 0x00001A26, 0x00001B25, 0x00001B25,
	0x00001C24, 0x00001C24, 0x00001D23, 0x00001D23,
	0x00001E22, 0x00001E22, 0x00001F21, 0x00001F21,
	0x00002020, 0x0000211F, 0x0000211F, 0x0000221E,
	0x0000221E, 0x0000231D, 0x0000231D, 0x0000241C,
	0x0000241C, 0x0000251B, 0x0000251B, 0x0000261A,
	0x0000261A, 0x00002719, 0x00002818, 0x00002917,
};

static unsigned int sc_tab_2taps_type2[32] = {
	0x0000112F, 0x0000122E, 0x0000132D, 0x0000142C,
	0x0000152B, 0x0000152B, 0x0000162A, 0x00001729,
	0x00001828, 0x00001927, 0x00001A26, 0x00001B25,
	0x00001C24, 0x00001D23, 0x00001E22, 0x00001F21,
	0x00002020, 0x0000211F, 0x0000221E, 0x0000231D,
	0x0000241C, 0x0000251B, 0x0000261A, 0x00002719,
	0x00002818, 0x00002917, 0x00002A16, 0x00002B15,
	0x00002B15, 0x00002C14, 0x00002D13, 0x00002E12,
};

static unsigned int sc_tab_2taps_type3[32] = {
	0x00001828, 0x00001828, 0x00001927, 0x00001A26,
	0x00001A26, 0x00001A26, 0x00001B25, 0x00001C24,
	0x00001C24, 0x00001C24, 0x00001D23, 0x00001E22,
	0x00001E22, 0x00001E22, 0x00001F21, 0x00002020,
	0x00002020, 0x00002020, 0x0000211F, 0x0000221E,
	0x0000221E, 0x0000221E, 0x0000231D, 0x0000241C,
	0x0000241C, 0x0000241C, 0x0000251B, 0x0000261A,
	0x0000261A, 0x0000261A, 0x00002719, 0x00002818,
};

static unsigned int sc_tab_2taps_type4[32] = {
	0x00001C24, 0x00001C24, 0x00001C24, 0x00001C24,
	0x00001D23, 0x00001E22, 0x00001E22, 0x00001E22,
	0x00001E22, 0x00001E22, 0x00001E22, 0x00001E22,
	0x00001F21, 0x00002020, 0x00002020, 0x00002020,
	0x00002020, 0x00002020, 0x00002020, 0x00002020,
	0x0000211F, 0x0000221E, 0x0000221E, 0x0000221E,
	0x0000221E, 0x0000221E, 0x0000221E, 0x0000221E,
	0x0000231D, 0x0000241C, 0x0000241C, 0x0000241C,
};

struct se_scaling_coef {
	unsigned long tab0_addr;
	unsigned long tab1_addr;
	unsigned int ratio;
	int shift_ctl;
	int sub;
};

static struct se_scaling_coef scaling_coef_tab8_arX[5] = {
	{ 0, 0,   0x0000F000,    0,          1, },
	{ 0, 0,   0x00015555,    0,          1, },
	{ 0, 0,   0x00020000,    0,          1, },
	{ 0, 0,   0x00040000,    1,          1, },
	{ 0, 0,   0x00060000,    2,          1, },
};

static struct se_scaling_coef scaling_coef_tab4_arY[5] = {
	{ 0, 0,   0x0001E000,    0,          1, },
	{ 0, 0,   0x00020000,    1,          1, },
	{ 0, 0,   0x0002aaaa,    1,          1, },
	{ 0, 0,   0x00040000,    2,          2, },
	{ 0, 0,   0x00080000,    3,          2, },
};

static struct se_scaling_coef scaling_coef_tab2_arY[5] = {
	{ 0, 0,   0x0001E000,    0,          1, },
	{ 0, 0,   0x00020000,    1,          1, },
	{ 0, 0,   0x0002aaaa,    1,          1, },
	{ 0, 0,   0x00040000,    2,          2, },
	{ 0, 0,   0x00080000,    3,          2, },
};
/* scaling coefficients table end */

#endif /* __CSP_DPU_SE_COEF_TAB_C__ */

